<?php
/**
 * 楼层品牌商品管理
 * @author Ice iceinto@mallog.com.cn
 */
class FloorBrandGoodModel extends BaseModel
{
    /**
     * 获取商品信息
     * @param Int $mId 商场ID
     * @param Int $fId 楼层ID
     * @param Int $bId 品牌ID
     * @author Ice iceinto@mallog.com.cn
     */
    public function getFloorBrandGood ($mId, $fId, $bId)
    {
        $map = array();
        $map['m_floor_brand_good.g_m_id'] = $mId;
        $map['m_floor_brand_good.g_f_id'] = $fId;
        $map['m_floor_brand_good.g_b_id'] = $bId;
        $Page = $this->getPage($this->where($map)->count());
        $rs['page'] = $Page->show();
        $rs['data'] = $this->join(
        'LEFT JOIN m_good ON m_good.g_id = m_floor_brand_good.g_g_id')
            ->where($map)
            ->limit($Page->firstRow.','.$Page->listRows)
            ->field('m_good.* , m_floor_brand_good.*')
            ->select();
        return $rs;
    }
    /**
     * 执行商品添加操作
     * @param Array $data 商品信息包
     * @author Ice iceinto@mallog.com.cn
     */
    public function fbgAddMore ($data)
    {
        $a = 0;
        $e = 0;
        $gData = $data['g_g_id'];
        $count = count($gData);
        foreach ($gData as $k => $d) {
            $data['g_g_id'] = $d;
            //唯一性判断
            if ($this->where($data)->find()) {
                $e ++;
            } else {
                if ($this->add($data)) {
                    $a ++;
                } else {
                    $e ++;
                }
            }
        }
        return '共 ' . $count . '商品 ,成功添加' . $a . ',失败 ' . $e;
    }
}
?>